Optimize instance Eq NormalizedFilePath#630
Draft
sjakobi wants to merge 1 commit intohaskell:masterfrom
Draft
Conversation
The `Ord` instance is also changed for consistency. Closes haskell#629.
sjakobi
commented
Nov 19, 2025
| deriving stock (Generic) | ||
|
|
||
| instance Eq NormalizedFilePath where | ||
| NormalizedFilePath _uri1 fp1 == NormalizedFilePath _uri2 fp2 = fp1 == fp2 |
Member
Author
There was a problem hiding this comment.
This should be a bit faster when comparing arbitrary NFPs, but slower for NFPs that are likely to be equal, such as in HashMap operations:
Suggested change
| NormalizedFilePath _uri1 fp1 == NormalizedFilePath _uri2 fp2 = fp1 == fp2 | |
| NormalizedFilePath (NormalizedUri h1 _) fp1 == NormalizedFilePath (NormalizedUri h2 _) fp2 = | |
| h1 == h2 && fp1 == fp2 |
michaelpj
reviewed
Nov 21, 2025
| deriving stock (Generic) | ||
|
|
||
| instance Eq NormalizedFilePath where | ||
| NormalizedFilePath _uri1 fp1 == NormalizedFilePath _uri2 fp2 = fp1 == fp2 |
Collaborator
There was a problem hiding this comment.
Definitely needs a comment!
Suggested change
| NormalizedFilePath _uri1 fp1 == NormalizedFilePath _uri2 fp2 = fp1 == fp2 | |
| -- We assume that filepath normalization does not change across the lifetime of HLS, so that | |
| -- if we have two `NormalizedFilePath`s with the same filepath, they also have the same | |
| -- normalized URI. | |
| NormalizedFilePath _uri1 fp1 == NormalizedFilePath _uri2 fp2 = fp1 == fp2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
Ordinstance is also changed for consistency.Closes #629.